Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getVisibleElements helper in RTL-locales #12464

Merged

Conversation

baloone
Copy link
Contributor

@baloone baloone commented Oct 9, 2020

This PR fixes #12453. I'm not sure about the name of the auxiliary function isElementNextAfterViewHorizontally.

@baloone baloone force-pushed the Fix_getVisibleElements_in_rtl_direction branch from e1cadbe to abe126e Compare October 9, 2020 14:26
@baloone baloone marked this pull request as draft October 9, 2020 14:29
@baloone baloone force-pushed the Fix_getVisibleElements_in_rtl_direction branch from abe126e to 8e43606 Compare October 9, 2020 14:54
@baloone baloone marked this pull request as ready for review October 9, 2020 14:58
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Oct 9, 2020

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/c4d1387ab62fd81/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Oct 9, 2020

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/c4d1387ab62fd81/output.txt

Total script time: 3.48 mins

Published

@timvandermeij
Copy link
Contributor

@Snuffleupagus If you have time, could you take a look at this PR? It looks reasonable to me, but my experience with the (not so trivial) getVisibleElements function is limited.

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that we have unit tests for the getVisibleElements function in test/unit/ui_utils_spec.js. I don't know how difficult this it to test, but it would be great if you could extend the unit tests for this PR so that we prevent this from regressing again in the future.

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #12464 (review), we need at least a basic unit-test for this (called e.g. handles horizontal scrolling with RTL-documents correctly).
I'd suggest defining a suitable scrollEl, similar but obviously not identical to

it("handles `sortByVisibility` correctly", function () {
const scrollEl = {
scrollTop: 75,
scrollLeft: 0,
clientHeight: 750,
clientWidth: 1500,
};
with pages defined e.g. as in
const pages = makePages([
[
[10, 50],
[20, 20],
[30, 10],
],
]);
and with the test doing something like

const visibleSorted = getVisibleElements(
  scrollEl,
  views,
  /* sortByVisibility = */ true,
  /* horizontal = */ true,
  /* rtl = */ true
);

and then checking that visibleSorted has the expected order (see how that's implemented in the existing test).

web/base_viewer.js Outdated Show resolved Hide resolved
web/base_viewer.js Outdated Show resolved Hide resolved
@baloone baloone force-pushed the Fix_getVisibleElements_in_rtl_direction branch from 8e43606 to b7b048e Compare October 20, 2020 21:34
@baloone
Copy link
Contributor Author

baloone commented Oct 20, 2020

I added the two suggested changes and a test

@baloone baloone requested a review from timvandermeij October 20, 2020 22:26
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/305b37fbe8570e2/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/305b37fbe8570e2/output.txt

Total script time: 4.07 mins

Published

@timvandermeij
Copy link
Contributor

/botio-linux unittest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/b79b13490fda154/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/b79b13490fda154/output.txt

Total script time: 4.30 mins

  • Unit Tests: Passed

@timvandermeij timvandermeij merged commit 0d1a874 into mozilla:master Oct 24, 2020
@timvandermeij
Copy link
Contributor

Thank you for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Regression] The getVisibleElements helper function is broken in RTL-locales
4 participants